package com.rongke.web.api;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.rongke.commons.JsonResp;
import com.rongke.mapper.TdEducationInfoMapper;
import com.rongke.model.TdEducationInfo;
import com.rongke.service.TdEducationInfoService;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.math.BigInteger;
import java.util.List;

/**
 * @TdEducationInfoController
 * @Controller
 * @version : Ver 1.0
 */
@RestController
@RequestMapping(value="/api/tdEducationInfo")
@Transactional
@CrossOrigin
public class TdEducationInfoController {
    private Logger log = Logger.getLogger(this.getClass());
    @Autowired
    private TdEducationInfoService tdEducationInfoService;

    /**
     * @添加
     * @param tdEducationInfo
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public JsonResp addTdEducationInfo(@RequestBody TdEducationInfo tdEducationInfo){
        log.debug("添加");
        tdEducationInfoService.insert(tdEducationInfo);
        return JsonResp.ok(tdEducationInfo);
    }

    /**
     * @修改
     * @param tdEducationInfo
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/update", method = RequestMethod.POST)
    public JsonResp updateTdEducationInfo(@RequestBody TdEducationInfo tdEducationInfo){
        log.debug("修改");
        tdEducationInfoService.updateById(tdEducationInfo);
        return JsonResp.ok(tdEducationInfo);
    }
    /**
     * @根据id查找
     * @param id
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/selectOne", method = RequestMethod.GET)
    public JsonResp selectTdEducationInfo(Long id){
        log.debug("查找");
        EntityWrapper ew = new EntityWrapper();
        ew.eq("user_id",id);
        TdEducationInfo tdEducationInfo = tdEducationInfoService.selectOne(ew);
        return JsonResp.ok(tdEducationInfo);
    }


}
